<template>
	<view>
		<view style="overflow: hidden;">
			<view class="u-m-40 u-font-40" v-html="details.title" style="font-weight: bold;"></view>		
			<view class="u-m-40 u-tips-color">
				<uni-dateformat :date="details.inTime*1000" :format="details.year==year?'M月dd日 hh:mm':'yyyy月M月dd日 hh:mm'"></uni-dateformat>
			</view>
			<view class="u-m-40 detial">
				<rich-text :nodes="details.content"></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
let timestamp = Date.parse(new Date());
import uniDateformat from 'components/uni-dateformat/uni-dateformat.vue';
let date = new Date(timestamp);
	export default {
		data() {
			return {
				title:'',
				details:'',
				details_data:{},
				year:date.getFullYear()
			}
		},
		components: {
			uniDateformat
		},
		onShow:function(){
		},
		onLoad:function(data){
			this.details_data._id = data._id;
			this.$u.api.getArticleInfo(this.details_data).then(res=>{
				var date = new Date(res.data.inTime*1000);
				res.data.year = date.getFullYear();
				var regex = new RegExp('<img', 'gi');
				res.data.content = res.data.content.replace(regex, `<img style="max-width: 100%; height: auto"`)
				this.details = res.data;
				console.log(this.details)
			})
		},
		methods: {

		}
	}
</script>

<style>
	page{
		background-color: #fff;
	}
	.detial img{
		width: 100%;
	}
</style>
